﻿using System.Windows.Forms;

namespace Appify
{
    using System.ComponentModel;

    [Designer(typeof(AppDirectoryDesigner))]
    public partial class AppDirectory : UserControl
    {

        public AppSource Source { get; set; }

        public AppDirectory()
        {
            InitializeComponent();
        }

        public void Reload()
        {
            AppsPanel.Controls.Clear();
            foreach (var app in Source.ToList())
            {
                AppsPanel.Controls.Add(this.apptoitem(app));
            }
        }

        private AppItem apptoitem(App a)
        {
            var r = new AppItem();

            r.NameLbl.Text = a.Name;
            r.IconPb.Image = a.Icon;
            return r;
        }
    }
}
